package com.ruoyi.home.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.home.domain.ScheduleVo;
import com.ruoyi.home.service.ScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static com.ruoyi.common.core.domain.AjaxResult.success;

/**
 * @author 梁国瑞
 * @version 1.0
 */
@RestController("homeScheduleController")
@RequestMapping("/home/schedule")
public class ScheduleController {
    // 引入Service层
    @Autowired
    private ScheduleService scheduleService;
    // 1. 根据当前登录者所属部门,查询管理员当前部门及子部门下的所有员工信息,以及员工的本月所有日报情况
    @GetMapping("/getSchedule")
    public AjaxResult getSchedule(@RequestParam(value = "month", required = false) String month) {
        //查询到当前用户id
        LoginUser loginUser = SecurityUtils.getLoginUser();
        Long userId = loginUser.getUserId();
        List<ScheduleVo> schedules = scheduleService.getSchedule(userId, month);
        return success(schedules);
    }

}
